﻿using System;
using System.IO;
using System.Linq;

namespace Letspirate.MapEngine.Tests.Unit.Stubs
{
    internal class StreamStub : Stream
    {
        private byte[] _array; 
        
        public StreamStub()
        {
            _array = new byte[0];
        }

        #region Overrides of Stream

        public override void Flush()
        {
            
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            throw new NotImplementedException();
        }

        public override void SetLength(long value)
        {
            throw new NotImplementedException();
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
            throw new NotImplementedException();
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            buffer = buffer.Skip(offset).Take(count).ToArray();
            _array = _array.Concat(buffer).ToArray();
        }

        public override bool CanRead
        {
            get { throw new NotImplementedException(); }
        }

        public override bool CanSeek
        {
            get { return false; }
        }

        public override bool CanWrite
        {
            get { return true; }
        }

        public override long Length
        {
            get { return _array.LongLength; }
        }

        public override long Position
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        #endregion
    }
}
